package com.bdqn.t330.ch12.controller;

import com.bdqn.t330.ch12.entity.City;
import com.bdqn.t330.ch12.entity.Province;
import com.bdqn.t330.ch12.service.ProvinceService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/province")
public class ProvinceController {

    @Resource
    ProvinceService provinceService;

    @ResponseBody
    @RequestMapping("/getlist")
    public Object getList() {
        List<Province> list = provinceService.getListService();
        return list;
    }

    @ResponseBody
    @RequestMapping("/getcitylist")
    public Object getCityList(@RequestParam int provinceId) {
        System.out.println("provinceId:" + provinceId);
        //List<Province> list = provinceService.getListService();
        List<City> list = provinceService.findByIdService(provinceId);
        return list;
    }
}
